//
//  HMStatus.swift
//  Faner_Weibo
//
//  Created by 范英强 on 16/1/30.
//  Copyright © 2016年 范英强. All rights reserved.
//

import UIKit

class HMStatus: NSObject {
    //注意在iphone 5上系统是32位 使用int 系统会默认是32的
    var id :Int64 = 0
    //微博内容
    var text: String?
    
    //用户
    var user: HMUser?
    
    var created_at: String?
    
    var source: String?
    //	int	转发数
    //	int	评论数
    //	int	表态数
    var reposts_count: Int = 0
    var comments_count: Int = 0
    var attitudes_count: Int = 0
    
    var retweeted_status: HMStatus?
    
    var pic_urls:[HMStatusPictureInfo]?
    
    init(dict:[String: AnyObject]) {
        super.init()
        setValuesForKeysWithDictionary(dict)
    }
    
    override func setValue(value: AnyObject?, forKey key: String) {
        if key == "user" {
            
            user = HMUser(dict: value as! [String: AnyObject])
            
        }else if key == "retweeted_status" {
            
            if let dict = value as? [String : AnyObject]{
               retweeted_status = HMStatus(dict: dict)
            }
            
        }else if key == "pic_urls"{
            
            if let array = value as? [[String :AnyObject]] {
                var tempArray = [HMStatusPictureInfo]()
                
                for dict in array {
                    tempArray.append(HMStatusPictureInfo(dict: dict))
                }
                
                pic_urls = tempArray
                print("听说\(pic_urls)")
            }
            
        }else{
            super.setValue(value, forKey: key)
        }
        
            
    }
    override func setValue(value: AnyObject?, forUndefinedKey key: String) {
    }
    
    override var description: String {
        let key = ["text"]
        return dictionaryWithValuesForKeys(key).description
    }


}
